package edu.gmu.projects.fireresponder.environment;

import java.util.Collection;
import java.util.Set;

public abstract class Asset implements Comparable<Asset> {
	public static enum AssetStatus {
		TEAM_MEMBER_UNABLE, FR_UNABLE, COMPLETE, BLOCKED, IN_PROGRESS, NOT_IN_PROGRESS
	};

	private AssetStatus status = AssetStatus.NOT_IN_PROGRESS;
	private double probabilityOfFire = 0;
	private double probabilityOfPresence = 0;
	private double relevanceValue = 0;
	private String id;

	@Override
	public int hashCode() {
		return 31 + id.hashCode();
	}

	@Override
	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null)
			return false;
		if (getClass() != o.getClass())
			return false;
		final Asset a = (Asset) o;
		if (id.compareTo(a.id) != 0)
			return false;
		return true;
	}

	public AssetStatus getStatus() {
		return status;
	}

	public void setStatus(AssetStatus status) {
		this.status = status;
	}

	public double getProbabilityOfFire() {
		return probabilityOfFire;
	}

	public void setProbabilityOfFire(double probability) {
		probabilityOfFire = probability;
	}

	public double getProbabilityOfPresence() {
		return probabilityOfPresence;
	}

	public void setProbabilityOfPresence(double probability) {
		probabilityOfPresence = probability;
	}

	public double getRelevanceValue() {
		return relevanceValue;
	}

	public void setRelevanceValue(double value) {
		relevanceValue = value;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public boolean intersects(Asset other) {
		Set<Location> myPoints = getPoints();
		for (Location l : other.getPoints()) {
			if (myPoints.contains(l)) {
				return true;
			}
		}
		return false;
	}

	public abstract Location getCenter();

	public abstract Collection<Asset> getConnectedAssets();

	public abstract int getEstimatedTimeToComplete();

	public abstract Set<Location> getPoints();
}